package com.windward.vii.web.controller;

import com.windward.vii.service.StatisticsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping(value = "/")
public class StatisticsController {

    private static final Logger logger = LoggerFactory.getLogger(StatisticsController.class);

    @Resource
    StatisticsService statisticsService;

    @RequestMapping(value = "v1/api0/sms/statistics/{id}", method = RequestMethod.GET)
    public String smsStatistics(@PathVariable String id,
                            HttpServletRequest request) {
        logger.info("smsStatistics: id={}", id);
        logger.info("smsStatistics: uri={}", request.getRequestURI());
        statisticsService.smsStatistics(request.getRequestURI());
        return "redirect:https://itunes.apple.com/cn/app/vii/id1268504473?mt=8";
    }


    public static void main(String[] args) {
        for(int i = 16; i <= 100; i++) {
            String url = "https://windwardapp.net/v1/api0/sms/statistics/";
            System.out.println(url+i);
        }
    }
}
